import { createApp } from 'vue'
// import './style.css'
import App from './App.vue'
import router from './router'
import api from './api'


const app=createApp(App)
// 在实例上绑定属性
app.config.globalProperties.$api=api

router.beforeEach((to,from)=>{
// if(to.path!=='login'){
// if(localStorage.getItem('h5_token')){
//     return '/login'
// }
// }
const token = localStorage.getItem("h5_token");
if (!token && to.path !== "/login") {
    return "/login";
  } else if (token && to.path === "/login") {
    return "/";
  } else {
    return true;
  }
})

app.use(router)
app.mount('#app')
